<template>
	<div class="info-main">
		<h2>订单信息：</h2>
		<a @click="playInfo"><van-btn text="确认订单" type="1" /></a>
	</div>
</template>

<script>
	import vanBtn from '../../common/vanBtn';
	import { requeSubmitPay } from '@/api/';
	export default {
		components: {
			vanBtn
		},
		data() {
			return {
				message: ''
			}
		},
		methods: {
			async playInfo(){
				const res = await this.getInfo();
				if(res){
					//发起跳转
					this.$router.push({
						path: res.payUrl,
						query: {}
					});
				}else{
					this.toast('支付发起失败');
				}
			},
			getInfo(){
				// orderNum固定1，orderType：0：金币购买，1：期权股购买
				return new Promise((resolve, reject) => {
					requeSubmitPay({
						orderAmt: '',
						orderType: '',
						orderNum: ''
					})
						.then(res => {
							let data = '';
							if (res.code === 200 && res.data) {
								data = res.data;
							}
							resolve(data);
						})
						.catch(msg => {
							resolve(false);
						});
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	.info-main{
		
	}
</style>
